<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('系统管理员操作界面')"/>
    <link th:href="@{/ruoyi/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/ruoyi/css/jquery-confirm.min.css}" rel="stylesheet"/>
</head>
<style type="text/css">
    .table {
        table-layout: fixed;
    }
    #macdz_id {
        width: 80%;
        margin: -30px 0px 0px 0px;
        height: 32px;
        float: right;
        border: none;
        border-bottom: 1px solid #e5e6e7;
    }
    #macdz_id > input {
        height: 21px;
        width: 26.3px;
        border: none;
        text-align: center;
    }
    #macdz_id > input[readonly] {
        background-color: #EEEEEE;
    }
    #ipdz_id {
        width: 80%;
        margin: -30px 0px 0px 0px;
        height: 32px;
        float: right;
        border: none;
        border-bottom: 1px solid #e5e6e7;
    }
    #ipdz_id > input {
        height: 21px;
        width: 32.3px;
        border: none;
        text-align: center;
    }
    #ipdz_id > input[readonly] {
        background-color: #EEEEEE;
    }
    .qbinput{
        margin: -10% 0px 0px 0px;
        float: right;
        width: 80%;
    }

    .bminput{
        margin: -10% 31% 0px 0px;
        float: right;
        width: 49%;
    }
    .shiyrinput{
        margin: -10% 0px 0px 0px;
        float: right;
        width: 30%;
    }

    .labkz{
        margin-top: 10px;
        float: left;
    }

    .xsqinputk{
        margin: -10% 20% 0px 0px;
        float: right;
        width: 60%;
    }
    .ypinputk{
        margin: -10% 20% 0px 0px;
        float: right;
        width: 60%;
    }
    .scsbbhinput{
        margin: -10% 34% 0px 0px;
        float: right;
        width: 46%;
    }
    .scbsbhdiv{
        float: right;margin-top: -10%
    }
    .fddiv{
        float: right;
        margin: -10% 0px 0px 0px;
    }
    .ypdiv{
        float: right;
        margin: -10% 0px 0px 0px;
    }
    .gmrqdiv{
        margin-right: 4%; width:72%;float: right
    }
    .rowdiv{
        margin-top: -2%;
    }
</style>
<body class="gray-bg" style="width: 95%;margin: 0px auto">
<div class="container-div">
    <form id="form-sb-add" class="form-horizontal">
        <div class="row">
            <div class="form-group">
                <h1><strong>添加设备</strong></h1>
            </div>
        </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">设备类型</label>
                <div class="col-sm-2">
                    <select name="sbbh_sel" id="sbbh_sel" class="form-control qbinput" onchange="sbbhchange()">
                    </select>
                    <input type="hidden" id="maxbh" name="maxbh">
                </div> </div>
        </div>
                <div class="row rowdiv"><div class="form-group">
                <label class="col-sm-2 control-label labkz">设备名称</label>
                <div class="col-sm-2">
                    <input name="sbbh" placeholder="请点击生成设备编号" id="sbbh_id" class="form-control scsbbhinput"
                           type="text"
                           readonly="readonly"
                           style="background-color: #FFFFFF"
                           required="required"></div>
                <div class="col-sm-2" style="display: none">
                    <input name="sbmc" id="sbmc_id" class="form-control qbinput" type="text"
                           placeholder="请输入设备名称"
                           readonly="readonly" style="background-color: #ffffff">
                    <input type="hidden" id="sbmc_option">
                    <input type="hidden" id="sbmc_index">
                    <input type="hidden" id="gsidfrotj" name="gsid">
                </div>
                <div class="col-sm-1">
                    <a class="btn btn-primary btn-rounded btn-sm scbsbhdiv" id="creat_sbbh_btn" onclick="scqcode()">
                        <i class="fa fa-search"></i>生成设备编号</a>
                </div>
                <!--<div class="col-sm-1"><img src="/img/700.gif" style="margin-left: -25px;width: 200%"></div>-->
                </div></div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">品牌型号</label>
                <div class="col-sm-2">
                    <input name="guige" id="guige_id" class="form-control qbinput" type="text"
                           placeholder="请输入品牌型号" required="required">
                </div>
            </div></div>
        <div class="row rowdiv"><div class="form-group">
                <label class="col-sm-2 control-label labkz">生产厂家</label>
                <div class="col-sm-2">
                    <input name="shccj" id="shccj_id" class="form-control qbinput" type="text"
                           placeholder="请输入生产厂家">
                </div></div> </div>
        <div class="row rowdiv"><div class="form-group">
                <label class="col-sm-2 control-label labkz">购买日期</label>
                <div class="col-sm-2 input-group date gmrqdiv">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="gmrq" id="gmrq_id" class="form-control" type="text"
                           readonly="readonly" placeholder="yyyy-MM-dd"
                           style="background-color: #FFFFFF;">
                    <input name="xsqgmrq" id="xsqgmrq_id"  type="hidden" placeholder="请输入备注">
                </div>
            </div>
        </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">主板型号</label>
                <div class="col-sm-1">
                    <input name="zbxh" id="zbxh_id" class="form-control qbinput" type="text"
                           placeholder="请输入主板型号">
                </div></div> </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">CPU型号</label>
                <div class="col-sm-1">
                    <input name="cpuxh" id="cpuxh_id" class="form-control qbinput" type="text"
                           placeholder="请输入CPU型号">
                </div>
            </div> </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">显卡型号</label>
                <div class="col-sm-1">
                    <input name="xkxh" id="xkxh_id" class="form-control qbinput" type="text"
                           placeholder="请输入显卡型号">
                </div>
            </div> </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">内存大小</label>
                <div class="col-sm-1">
                    <input name="ncggdx" id="ncggdx_id" class="form-control qbinput" type="text"
                           onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                           onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                           placeholder="请输入内存大小只能输入数字">
                </div>
            </div>
        </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">IP&nbsp;&nbsp;地&nbsp;&nbsp;址</label>
                <div class="col-sm-1" id="ipdz_id" >
                    <input type="text" value="" id="ipdz1" class="ip1" maxlength="3">.<input
                        type="text" value="" id="ipdz2" class="ip2" maxlength="3">.<input
                        type="text" value="" id="ipdz3" class="ip3" maxlength="3">.<input
                        type="text" value="" id="ipdz4" class="ip4" maxlength="3">
                </div></div></div>
                <input type="hidden" name="ipdz" id="ip">
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">MAC地址</label>
                <div class="col-sm-1" id="macdz_id">
                    <input type="text" value="" class="mac1" maxlength="2" style="width: 25px">-
                    <input type="text" value="" class="mac2" maxlength="2" style="width: 25px">-
                    <input type="text" value="" class="mac3" maxlength="2" style="width: 25px">-
                    <input type="text" value="" class="mac4" maxlength="2" style="width: 25px">-
                    <input type="text" value="" class="mac5" maxlength="2" style="width: 25px">-
                    <input type="text" value="" class="mac6" maxlength="2" style="width: 25px">
                </div></div></div>
                <input type="hidden" name="macdz" id="mac">
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">使用部门</label>
                <div class="col-sm-1">
                    <select name="bm" class="form-control m-b bminput" id="bmid_id" onchange="getry()">
                    </select>
                </div>
                <div class="col-sm-1">
                    <input name="shiyr" id="shiyr_id" class="form-control shiyrinput" list="browsers" placeholder="姓名拼音">
                    <datalist id="browsers"></datalist>
                    <span class="help-block"></span>
                </div>
            </div>
        </div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">显&nbsp;&nbsp;示&nbsp;&nbsp;器</label>
                <div class="col-sm-1">
                    <input name="xsqppcc" id="xsqppcc_id" class="form-control xsqinputk"
                           placeholder="显示器品牌尺寸信息"
                           readonly="readonly">
                    <span class="help-block"></span>
                </div>
                <div class="col-sm-1 fddiv">
                    <a class="btn btn-rounded btn-primary btn-sm" id="xsqcc_btn">显示器</a>
                    <span class="help-block"></span>
                </div></div></div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">硬盘信息</label>
                <div class="col-sm-1">
                    <input name="ypdx" id="ypdx_id_1" class="form-control ypinputk" type="text"
                           readonly="readonly"
                           placeholder="请点击硬盘一按钮     ">
                </div>
                <div class="col-sm-1 ypdiv">
                    <a class="btn btn-primary btn-rounded btn-sm" id="ypdx_btn_1">硬盘一</a>
                </div>
            </div></div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz" >硬盘信息</label>
                <div class="col-sm-1">
                    <input name="ypdx" id="ypdx_id_2" class="form-control ypinputk" type="text"
                           readonly="readonly"
                           placeholder="请点击硬盘二按钮     ">
                </div>
                <div class="col-sm-1 ypdiv">
                    <a class="btn btn-rounded btn-primary btn-sm" id="ypdx_btn_2">硬盘二</a>
                </div>
            </div></div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">硬盘信息</label>
                <div class="col-sm-1">
                    <input name="ypdx" id="ypdx_id_3" class="form-control ypinputk" type="text"
                           readonly="readonly"
                           placeholder="请点击硬盘三按钮     "
                           style="text-align:left;padding-right: 3px;padding-left: 3px;background-color: #FFFFFF">
                </div>
                <div class="col-sm-1 ypdiv">
                    <a class="btn btn-rounded btn-primary btn-sm" id="ypdx_btn_3">硬盘三</a>
                    <!--<a class="btn btn-rounded btn-primary btn-sm " onclick="dianj()">点击看看</a>-->
                </div>
            </div></div>
        <div class="row rowdiv">
            <div class="form-group">
                <label class="col-sm-2 control-label labkz">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</label>
                <div class="col-sm-10">
                    <input name="beiz" id="beiz_id" class="form-control qbinput" type="text"
                           placeholder="请输入备注">
                    <input name="sjbeiz" id="sjbeiz_id" type="hidden" placeholder="请输入备注">
                    <input name="bfbeiz" id="bfbeiz_id" type="hidden" placeholder="请输入备注">
                    <p style="display: none" id="pgsid">[[${session.gsid}]]</p>
                </div>
            </div>
        </div>
        <div class="row" style="display: none">
            <div class="col-sm-12">
                <div class="form-group">
                    <input name="went" disabled id="tj_text" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="row" style="display: none">
            <div class="col-sm-12">
                <div class="form-group">
                    <div id="tj_qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
                    <input name="qrcode" id="tj_qrcode_update_input_15" class="form-control" type="hidden">
                </div>
            </div>
        </div>
        <div class="row" style="height:30px">
            <div class="form-group">
                <div class="modal-footer">
                    <button type="button" style="margin-top: -20px" class="btn btn-white" id="sb_save_btn" onclick="savesb()">保存
                    </button>
                </div>
            </div>
        </div>
    </form>
</div>
<div><input type="hidden" id="_pageNumber"></div>
<div><input type="hidden" id="_pageSize"></div>
<!--<p>[[${url}]]</p>-->
<div th:replace="zdyyj :: myfooter"></div>
<th:block th:include="include :: footer"/>
<script th:src="@{/ruoyi/js/jquery-confirm.min.js}"></script>
<script th:src="@{/ruoyi/js/jquery.form.js}"></script>
<!--<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>-->
<script th:inline="javascript">

    // 下面这行和上面的script一起使用  获取真实IP地址
    // document.write(returnCitySN["cip"]+','+returnCitySN["cname"] + "真实IP地址")
    // document.write()
    // var url=returnCitySN["cip"]+'/:9090'
    // // 下面的一堆 单独使用 获取本地的IP地址
    // function findIP(callback) {
    //     var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
    //     var pc = new myPeerConnection({iceServers: []}),
    //         noop = function() {},
    //         localIPs = {},
    //         ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
    //         key;
    //
    //     function ipIterate(ip) {
    //         if (!localIPs[ip]) callback(ip);
    //         localIPs[ip] = true;
    //     }
    //     pc.createDataChannel("");
    //     pc.createOffer().then(function(sdp) {
    //         sdp.sdp.split('\n').forEach(function(line) {
    //             if (line.indexOf('candidate') < 0) return;
    //             line.match(ipRegex).forEach(ipIterate);
    //         });
    //         pc.setLocalDescription(sdp, noop, noop);
    //     });
    //     pc.onicecandidate = function(ice) {
    //         if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
    //         ice.candidate.candidate.match(ipRegex).forEach(ipIterate);
    //     };
    // }
    //
    // findIP(function(ip){
    //     let dom = document.getElementById('dom')
    //     dom.innerHTML = ip + "你的本地IP地址"
    // });

    var gsid="";
    $(document).ready(function () {
        gsid=$("#pgsid").text()
        gettjmtk()
        getsblx("#sbbh_sel");
        getDepts("#bmid_id");
        getxsqpp();
            layui.use('laydate', function () {
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#gmrq_id',
                    type: 'date',
                    trigger: 'click'
                });
            });
        if (gsid == null) {
            $.alert("当前状态未登陆系统或浏览器中当前会话结束了，您需要重新登陆","温馨提示")
            window.location.href = "/login";
        }
    });

    var tj_qrcode = new QRCode(document.getElementById("tj_qrcode"), {
        width: 100,
        height: 100
    });

    function makeqrcode() {
        var elText = document.getElementById("tj_text");
        tj_qrcode.makeCode(elText.value);
    }

    makeqrcode()

    function sbbhsc() {
        var sb = $("#sbbh_sel option:selected").val();
        var sbmc = $("#sbbh_sel option:selected").text();
        $.ajax({
            url: "/sbgl/sbflb/maxbh/" + sb,
            type: 'GET',
            async: false,
            success: function (data) {
                $("#sbbh_id").val(data);
                $("#sbmc_id").val(sbmc);
            },
        })
        $('#tj_text').val('http://'+geturl()+':9090/sbgl/sbxxb/sbwh/' + $("#sbbh_id").val() + '/');
        makeqrcode();
        // var sbbh = obj.getAttribute("value");
        var tj_qrcode = document.getElementById("tj_qrcode").lastElementChild.outerHTML;
        $("#tj_qrcode_update_input_15").val(tj_qrcode);
    }

    //点击生成设备编号后的js
    $('#creat_sbbh_btn').click(function () {
        var sb = $("#sbbh_sel option:selected").val();
        var sbmc = $("#sbbh_sel option:selected").text();
        $.ajax({
            url: "/sbgl/sbflb/maxbh/" + sb,
            type: 'GET',
            async: false,
            success: function (data) {
                $("#sbbh_id").val(data);
                $("#sbmc_id").val(sbmc);
            },
        })
        $('#tj_text').val('http://'+geturl()+':9090/sbgl/sbxxb/sbwh/' + $("#sbbh_id").val() + '/');
        makeqrcode();
        // var sbbh = obj.getAttribute("value");
        var tj_qrcode = document.getElementById("tj_qrcode").lastElementChild.outerHTML;
        $("#tj_qrcode_update_input_15").val(tj_qrcode);
    });

    function getshiyr() {
        var shiyr = $("#shiyr_id").val();
        var bm = $("#bmid_id option:selected").text();
        var xinshiyr = ""
        $.ajax({
            url: "/sbgl/ygxxb/getbmbyshiyrandbm/" + shiyr + "/" + bm+"/"+gsid,
            type: "get",
            async: false,
            success: function (data) {
                xinshiyr = data
            }
        })
        return xinshiyr;
    }

    function geturl() {
        var geturl = ""
        $.ajax({
            url: "/geturl",
            type: "get",
            async: false,
            success: function (data) {
                geturl =data
            }
        })
        return $.trim(geturl);
    }

    //初始化表单数据
    function gettjmtk() {
        $("#sbbh_sel").val("")
        $("#sbbh_id").val("")
        $("#sbmc_id").val("")
        $("#guige_id").val("")
        $("#shccj_id").val("")
        $("#gmrq_id").val("")
        $("#bmid_id").val("")
        $("#shiyr_id").val("")
        $('#zbxh_id').val("")
        $('#cpuxh_id').val("")
        $('#ncggdx_id').val("")
        $('#xkxh_id').val("")
        $('#ypdx_id_1').val("")
        $('#ypdx_id_2').val("")
        $('#ypdx_id_3').val("")
        $('#xsqppcc_id').val("")
        $('#ipdz1').val("")
        $('#ipdz2').val("")
        $('#ipdz3').val("")
        $('#ipdz4').val("")
        $("#ip").val("");
        $("#mac").val("");
        $('.mac1').val("");
        $('.mac2').val("");
        $('.mac3').val("");
        $('.mac4').val("");
        $('.mac5').val("");
        $('.mac6').val("");
        $('#beiz_id').val("");
        $("#gsidfrotj").val(gsid)
        getDepts("#bmid_id");
        getsblx("#sbbh_sel");
        getxsqpp();
        $('#ypdx_btn_1').attr("disabled", "disabled").unbind("click")
        $('#ypdx_btn_2').attr("disabled", "disabled").unbind("click")
        $('#ypdx_btn_3').attr("disabled", "disabled").unbind("click")
        $('#xsqcc_btn').attr("disabled", "disabled").unbind("click")
        $('#creat_sbbh_btn').attr("disabled", "disabled").unbind("click")
        document.getElementById('xsqppcc_id').style.backgroundColor = "#ffffff"
        document.getElementById('ypdx_id_1').style.backgroundColor = "#ffffff"
        document.getElementById('ypdx_id_2').style.backgroundColor = "#ffffff"
        document.getElementById('ypdx_id_3').style.backgroundColor = "#ffffff"
    };

    function getsblx(ele) {
        $.ajax({
            url: '/sbgl/sbflb/getsbflb/' + gsid,
            type: 'get',
            async: false,
            success: function (data) {
                $(ele).empty();
                var options = "";   //字符串拼接
                $(ele).append('<option value="">请选择设备类型</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].sbid + "'>" + data[i].sbmc + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $(ele).append(options);
            }
        })
    }

    function getDepts(ele) {
        $.ajax({
            url: "/sbgl/ygxxb/getbm/" + gsid,
            type: 'get',
            async: false,
            success: function (data) {
                $(ele).empty();
                var options = "";   //字符串拼接
                $(ele).append('<option value="">请选择部门</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].bm + "'>" + data[i].bm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $(ele).append(options);
            },
        });
    };

    function getxsqpp() {
        $('#xsqpp_id').val("");
        $('#browsersforxsq').empty();
        $.ajax({
            url: "/sbgl/xsqxxb/getxsqxxb/",
            type: 'get',
            async: false,
            success: function (data) {
                $('#xsqpp_id').empty();
                var options = "";   //字符串拼接
                // $("#browsersforxsq").append('<option value="">请选择显示器品牌</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].xsqpp + "'>" + data[i].zjm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#browsersforxsq').append(options);
            },
        });
    };


    function getry() {
        var bm = $("#bmid_id option:selected").val();
        $('#shiyr_id').val("");
        $('#browsers').empty();
        $.ajax({
            url: "/sbgl/ygxxb/getygxx/" + bm+"/"+gsid,
            type: 'get',
            async: false,
            success: function (data) {
                $('#shiyr_id').empty();
                var options = "";   //字符串拼接
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].shiyr + "'>" + data[i].zjm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#browsers').append(options);
            },
        });
    }

    function getmaxbh() {
        var sbid = $("#sbbh_sel option:selected").val()
        var maxbh = ""
        $.ajax({
            url: "/sbgl/sbflb/maxbhforint/" + sbid + "/" + gsid,
            type: "get",
            async: false,
            success: function (data) {
                maxbh = data
            }
        })
        return maxbh
    }

    function updatesbflb() {
        var sbid = $("#sbbh_sel option:selected").val()
        $("#maxbh").val(getmaxbh())
        $.ajax({
            url: "/sbgl/sbflb/updatesbflb/" + sbid,
            type: "put",
            async: false,
            data: $("#form-sb-add").serialize(),
            success: function (data) {
            }
        })
    }

    function savesbenter() {
        if (event.keyCode == 13) {
            savesb()
        }
    }

    function savesb() {
        var sbbh_sel = $("#sbbh_sel").val()
        var ypdx_sel_1 = $("#ypdx_sel_1 option:selected").text();
        var ypdx_sel_2 = $("#ypdx_sel_2 option:selected").text();
        var ypdx_sel_3 = $("#ypdx_sel_3 option:selected").text();
        var sbbh_id = $("#sbbh_id").val()
        var sbmc_id = $("#sbmc_id").val()
        var guige_id = $("#guige_id").val()
        var shccj_id = $("#shccj_id").val()
        var gmrq_id = $("#gmrq_id").val()
        var bmid_id = $("#bmid_id").val()
        var shiyr_id = $("#shiyr_id").val()
        var zbxh_id = $('#zbxh_id').val()
        var cpuxh_id = $('#cpuxh_id').val()
        var ncggdx_id = $('#ncggdx_id').val()
        var xkxh_id = $('#xkxh_id').val()
        var ypdx_id_1 = $('#ypdx_id_1').val()
        var ypdx_id_2 = $('#ypdx_id_2').val()
        var ypdx_id_3 = $('#ypdx_id_3').val()
        var xsqppcc_id = $('#xsqppcc_id').val()
        var gsid=$("#pgsid").text()
        var ipdz1 = $('#ipdz1').val()
        var ipdz2 = $('#ipdz2').val()
        var ipdz3 = $('#ipdz3').val()
        var ipdz4 = $('#ipdz4').val()
        var macdz = $('.mac1').val();
        var index = ypdx_id_1.lastIndexOf("\-");
        var ypdx_id_shuzi_1 = ypdx_id_1.substring(index + 1, ypdx_id_1.length);
        var index = ypdx_id_2.lastIndexOf("\-");
        var ypdx_id_shuzi_2 = ypdx_id_2.substring(index + 1, ypdx_id_2.length);
        var index = ypdx_id_3.lastIndexOf("\-");
        var ypdx_id_shuzi_3 = ypdx_id_3.substring(index + 1, ypdx_id_3.length);
        if (sbbh_sel == "") {
            $("#sbbh_sel").focus()
            $.alert("请先选择设备类型","温馨提示")
        } else if (bmid_id == "") {
            $("#bmid_id").focus()
            $.alert("请点击选择部门的下拉框","温馨提示")
        } else if (gsid == "") {
            $.alert("当前状态未登陆系统或浏览器中当前会话结束了，您需要重新登陆","温馨提示")
            window.location.href = "/login";
        } else if (shiyr_id == "") {
            $("#shiyr_id").focus()
            $.alert("请输入姓名的助记码，助记码为拼音首字母","温馨提示")
        } else if (bmid_id != "" && shiyr_id != "") {
            var xinr = getshiyr()
            if (sbmc_id == "") {
                $.alert("请先选择设备类型后，点击生成设备编号按钮，谢谢您的合作！！！","温馨提示")
            } else if (sbbh_id == "") {
                $.alert("设备编号是自动生成的，点击生成设备编号按钮","温馨提示")
            } else if (guige_id == "") {
                $("#guige_id").focus()
                $.alert("请输入品牌型号","温馨提示")
            } else if (shccj_id == "") {
                $("#shccj_id").focus()
                $.alert("请输入生产厂家","温馨提示")
            } else if (gmrq_id == "") {
                $("#gmrq_id").focus()
                $.alert("请点击购买日期","温馨提示")
            } else if (zbxh_id == "" && sbmc_id.indexOf("脑") > 0) {
                $("#zbxh_id").focus()
                $.alert("请输入主板型号","温馨提示")
            } else if (cpuxh_id == "" && sbmc_id.indexOf("脑") > 0) {
                $("#cpuxh_id").focus()
                $.alert("请输入CPU型号","温馨提示")
            } else if (ncggdx_id == "" && sbmc_id.indexOf("脑") > 0) {
                $("#ncggdx_id").focus()
                $.alert("请输入内存大小","温馨提示")
            } else if (xkxh_id == "" && sbmc_id.indexOf("脑") > 0) {
                $("#xkxh_id").focus()
                $.alert("请输入显卡型号","温馨提示")
            } else if (ypdx_id_1 == "" && sbmc_id.indexOf("脑") > 0) {
                $("#ypdx_id_1").focus()
                $.alert("请输入硬盘大小","温馨提示")
            } else if (xsqppcc_id == "" && sbmc_id.indexOf("脑") > 0) {
                $("#xsqppcc_id").focus()
                $.alert("请输入显示器大小","温馨提示")
            } else if (ipdz1 == "" && sbmc_id.indexOf("脑") > 0) {
                $("#ipdz1").focus()
                $.alert("请输入IP地址","温馨提示")
            } else if (ipdz2 == "" && sbmc_id.indexOf("脑") > 0) {
                $("#ipdz2").focus()
                $.alert("请输入IP地址","温馨提示")
            } else if (ipdz3 == "" && sbmc_id.indexOf("脑") > 0) {
                $("#ipdz3").focus()
                $.alert("请输入IP地址","温馨提示")
            } else if (ipdz4 == "" && sbmc_id.indexOf("脑") > 0) {
                $("#ipdz4").focus()
                $.alert("请输入IP地址","温馨提示")
            } else if (macdz == "" && sbmc_id.indexOf("脑") > 0) {
                $(".mac1").focus()
                $.alert("请输入MAC物理地址","温馨提示")
            } else if (zbxh_id == "" && sbmc_id.indexOf("务器") > 0) {
                $("#zbxh_id").focus()
                $.alert("请输入主板型号","温馨提示")
            } else if (cpuxh_id == "" && sbmc_id.indexOf("务器") > 0) {
                $("#cpuxh_id").focus()
                $.alert("请输入CPU型号","温馨提示")
            } else if (ncggdx_id == "" && sbmc_id.indexOf("务器") > 0) {
                $("#ncggdx_id").focus()
                $.alert("请输入内存大小","温馨提示")
            } else if (xkxh_id == "" && sbmc_id.indexOf("务器") > 0) {
                $("#xkxh_id").focus()
                $.alert("请输入显卡型号","温馨提示")
            } else if (ypdx_id_1 == "" && sbmc_id.indexOf("务器") > 0) {
                $("#ypdx_id_1").focus()
                $.alert("请输入硬盘大小","温馨提示")
            } else if (xsqppcc_id == "" && sbmc_id.indexOf("务器") > 0) {
                $("#xsqppcc_id").focus()
                $.alert("请输入显示器大小","温馨提示")
            } else if (ypdx_id_shuzi_1 >= 50 && ypdx_sel_1 == "T") {
                $("#ypdx_id_1").val("");
                $.alert("硬盘1大小以T为单位，请输入的硬盘大小不能大于50T","温馨提示")
            } else if (ypdx_id_shuzi_1 <= 80 && ypdx_sel_1 == "G") {
                $("#ypdx_id_1").val("");
                $.alert("硬盘1大小以G为单位，请输入的硬盘大小必须大于80G","温馨提示")
            } else if (ypdx_id_shuzi_2 >= 50 && ypdx_sel_2 == "T") {
                $("#ypdx_id_2").val("");
                $.alert("硬盘2大小以T为单位，请输入的硬盘大小不能大于50T","温馨提示")
            } else if (ypdx_id_shuzi_2 <= 80 && ypdx_sel_2 == "G") {
                $("#ypdx_id_2").val("");
                $.alert("硬盘2大小以G为单位，请输入的硬盘大小必须大于80G","温馨提示")
            } else if (ypdx_id_shuzi_3 >= 50 && ypdx_sel_3 == "T") {
                $("#ypdx_id_3").val("");
                $.alert("硬盘3大小以T为单位，请输入的硬盘大小不能大于50T","温馨提示")
            } else if (ypdx_id_shuzi_3 <= 80 && ypdx_sel_3 == "G") {
                $("#ypdx_id_3").val("");
                $.alert("硬盘3大小以G为单位，请输入的硬盘大小必须大于80G","温馨提示")
            } else if (xinr == "全公司上下查无此人") {
                $("#shiyr_id").val("")
                $("#shiyr_id").focus();
                $.alert("你查询的员工信息不在你现在的部门里面，请核对","温馨提示")
            } else {
                updatesbflb()
                savesbforajax()
            }
        }
    }

    function savesbforajax() {
        $.ajax({
            url: "/sbgl/sbxxb/insertsb",
            type: 'POST',
            data: $("#form-sb-add").serialize(),
            success: function (result) {
                if (result != null) {
                    confirm("温馨提示","添加成功！！！")
                    window.location.href = "/sbgl/sbxxb/sbxxb"
                }
            }
        });
    }

    function confirm(title,content,ele) {
        $.confirm({
            title: title,
            content: content,
            buttons: {
                确定: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function(){
                        $(ele).modal('hide');
                    }
                }
            }
        });
    }

    function xsqxx() {
        $('#sbAddModal').modal('hide');
        $("#xsqppcc").val("");
        $.confirm({
            title: '显示器品牌尺寸信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请输入显示器品牌，点击下拉框选择显示器尺寸大小</label>' +
                // '<input id="xsqpp" class="xsqpp form-control" list="browsersforxsq" placeholder="品牌助记码">'+
                // '<datalist id="browsersforxsq"></datalist>'+
                '<input id="xsqpp" class="xsqpp form-control" placeholder="请输入显示器品牌">' +
                '<select id="xsqcc" class="xsqcc form-control"><option value="">请选择显示器尺寸</option><option value="13寸">13寸</option><option value="14寸">14寸</option><option value="15寸">15寸</option><option value="17寸">17寸</option><option value="19寸">19寸</option><option value="19.5寸">19.5寸</option><option value="20寸">20寸</option><option value="23.5寸">23.5寸</option><option value="24寸">24寸</option><option value="25寸">25寸</option><option value="G">27寸</option></select>' +
                '</div>' +
                '</form>',
            buttons: {
                qdformSubmit: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        var xsqpp = this.$content.find('.xsqpp').val();
                        var xsqcc = this.$content.find('.xsqcc').val();
                        if (!xsqpp) {
                            $.alert('请输入显示器品牌',"温馨提示");
                            return false;
                        }
                        if (!xsqcc) {
                            $.alert('请选择显示器尺寸大小',"温馨提示");
                            return false;
                        }
                        $("#xsqppcc_id").val(xsqpp + "-" + xsqcc);
                        this.close()
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            },
        });
    }

    $('#xsqcc_btn').click(function () {
        xsqxx()
    });


    var jxyp = "机械-";
    var gtyp = "固态-";

    function ypdx_1() {
        $('#sbAddModal').modal('hide');
        $("#ypdx_id_1").val("");
        $.confirm({
            title: '硬盘一信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<input type="text" placeholder="请输入硬盘大小，注意单位" class="name form-control"/>' +
                '<select class="ypdx form-control"><option value="T">T</option><option value="G">G</option> </select>' +
                '</div>' +
                '</form>',
            buttons: {
                jxypformSubmit: {
                    text: '机械硬盘',
                    btnClass: 'btn-blue',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('硬盘空间大小不能为空',"温馨提示");
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G',"温馨提示");
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T',"温馨提示");
                            return false;
                        }
                        $("#ypdx_id_1").val(jxyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },

                gtypformSubmit: {
                    text: '固态硬盘',
                    btnClass: 'btn-green',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('请输入硬盘大小',"温馨提示");
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G',"温馨提示");
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T',"温馨提示");
                            return false;
                        }
                        $("#ypdx_id_1").val(gtyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            },
        });
    }

    $('#ypdx_btn_1').click(function () {
        ypdx_1()
    });

    function ypdx_2() {
        $('#sbAddModal').modal('hide');
        $("#ypdx_id_2").val("");
        $.confirm({
            title: '硬盘一信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<input type="text" placeholder="请输入硬盘大小，注意单位" class="name form-control"/>' +
                '<select class="ypdx form-control"><option value="T">T</option><option value="G">G</option> </select>' +
                '</div>' +
                '</form>',
            buttons: {
                jxypformSubmit: {
                    text: '机械硬盘',
                    btnClass: 'btn-blue',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('硬盘空间大小不能为空',"温馨提示");
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G',"温馨提示");
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T',"温馨提示");
                            return false;
                        }
                        $("#ypdx_id_2").val(jxyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },

                gtypformSubmit: {
                    text: '固态硬盘',
                    btnClass: 'btn-green',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('请输入硬盘大小',"温馨提示");
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G',"温馨提示");
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T',"温馨提示");
                            return false;
                        }
                        $("#ypdx_id_2").val(gtyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            },
        });
    }

    $('#ypdx_btn_2').click(function () {
        ypdx_2()
    });

    function ypdx_3() {
        $('#sbAddModal').modal('hide');
        $("#ypdx_id_3").val("");
        $.confirm({
            title: '硬盘一信息',
            content: '' +
                '<form action="" class="formName">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<input type="text" placeholder="请输入硬盘大小，注意单位" class="name form-control"/>' +
                '<select class="ypdx form-control"><option value="T">T</option><option value="G">G</option> </select>' +
                '</div>' +
                '</form>',
            buttons: {
                jxypformSubmit: {
                    text: '机械硬盘',
                    btnClass: 'btn-blue',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('硬盘空间大小不能为空',"温馨提示");
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G',"温馨提示");
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T',"温馨提示");
                            return false;
                        }
                        $("#ypdx_id_3").val(jxyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },

                gtypformSubmit: {
                    text: '固态硬盘',
                    btnClass: 'btn-green',
                    action: function () {
                        var name = this.$content.find('.name').val();
                        var ypdx = this.$content.find('.ypdx').val();
                        if (!name) {
                            $.alert('请输入硬盘大小',"温馨提示");
                            return false;
                        }
                        if (name <= 80 && ypdx == "G") {
                            $.alert('硬盘空间单位为G，填写的硬盘大小不能小于80G',"温馨提示");
                            return false;
                        }
                        if (name >= 50 && ypdx == "T") {
                            $.alert('硬盘空间单位为T，填写的硬盘大小不能大于50T',"温馨提示");
                            return false;
                        }
                        $("#ypdx_id_3").val(gtyp + name + ypdx);
                        $('#sbAddModal').modal('show');
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        //close
                        $('#sbAddModal').modal('show');
                    },
                },
            }
        });
    }

    $('#ypdx_btn_3').click(function () {
        ypdx_3()
    });

    /**
     * 当ip和Mac有初始值时，将其拆开，显示在每一个文本框中
     * */
        //添加 Mac
    var macShow = "";
    var resultMac = macShow.split(":");
    $("#macdz_id>.mac1").val(resultMac[0]);
    $("#macdz_id>.mac2").val(resultMac[1]);
    $("#macdz_id>.mac3").val(resultMac[2]);
    $("#macdz_id>.mac4").val(resultMac[3]);
    $("#macdz_id>.mac5").val(resultMac[4]);
    $("#macdz_id>.mac6").val(resultMac[5]);

    // 添加ip
    var ipShow = "";
    var resultIp = ipShow.split(".");
    $("#ipdz_id>.ip1").val(resultIp[0]);
    $("#ipdz_id>.ip2").val(resultIp[1]);
    $("#ipdz_id>.ip3").val(resultIp[2]);
    $("#ipdz_id>.ip4").val(resultIp[3]);

    /**
     * mac发生变化时调用即可
     * 将每一个小格中的值获取到传给后台
     * 如果小格中没有值则传空值，有值则传value值，并在后面加上：封号，最后一个不用加
     * */
    function macc() {
        var mac1, mac2, mac3, mac4, mac5, mac6;
        if ($("#macdz_id>.mac1").val() == '') {
            mac1 = '';
        } else {
            mac1 = $("#macdz_id>.mac1").val() + '-';
        }
        if ($("#macdz_id>.mac2").val() == '') {
            mac2 = '';
        } else {
            mac2 = $("#macdz_id>.mac2").val() + '-';
        }
        if ($("#macdz_id>.mac3").val() == '') {
            mac3 = '';
        } else {
            mac3 = $("#macdz_id>.mac3").val() + '-';
        }
        if ($("#macdz_id>.mac4").val() == '') {
            mac4 = '';
        } else {
            mac4 = $("#macdz_id>.mac4").val() + '-';
        }
        if ($("#macdz_id>.mac5").val() == '') {
            mac5 = '';
        } else {
            mac5 = $("#macdz_id>.mac5").val() + '-';
        }
        if ($("#macdz_id>.mac6").val() == '') {
            mac6 = '';
        } else {
            mac6 = $("#macdz_id>.mac6").val();
        }
        var macc = mac1 + mac2 + mac3 + mac4 + mac5 + mac6;
        $("#mac").val(macc);
    }

    /**
     * ip发生变化时调用即可
     * 同Mac一样
     * */
    function ipp() {
        var ip1, ip2, ip3, ip4;
        if ($("#ipdz_id>.ip1").val() == '') {
            ip1 = '';
        } else {
            ip1 = $("#ipdz_id>.ip1").val() + '.';
        }
        if ($("#ipdz_id>.ip2").val() == '') {
            ip2 = '';
        } else {
            ip2 = $("#ipdz_id>.ip2").val() + '.';
        }
        if ($("#ipdz_id>.ip3").val() == '') {
            ip3 = '';
        } else {
            ip3 = $("#ipdz_id>.ip3").val() + '.';
        }
        if ($("#ipdz_id>.ip4").val() == '') {
            ip4 = '';
        } else {
            ip4 = $("#ipdz_id>.ip4").val();
        }
        var ipp = ip1 + ip2 + ip3 + ip4;
        $("#ip").val(ipp);
    }

    /**
     * mac地址格式
     * 键盘按方向键上下左右，光标在四个input中来回切换
     */
    $('#macdz_id>input').each(function (i, o) {
        $(this).attr('cust_index', i);
    })

    $('#macdz_update>input').each(function (i, o) {
        $(this).attr('cust_index', i);
    })

    $('#macdz_id>input').keydown(function (event) {
        var keycode = event.which;
        //从最后一个小格开始删除，删完之后直接跳到前一个小格中继续删除
        if (event.keyCode == 8 && $(this).val().length == 0) {
            $(this).prev().focus();
        }
        if (38 != keycode && 40 != keycode && 37 != keycode && 39 != keycode) {
            return;
        }
        var ti = $(this).attr('cust_index');
        if (39 == keycode || 40 == keycode) {
            //down
            ti++;
        } else {
            //up
            ti--;
        }
        if (ti < 0) {
            ti = 0;
        }
        var next_obj = $('#macdz_id>input[cust_index=' + ti + ']');
        if (next_obj) {
            next_obj.focus();
        }
    })

    /**
     * 限制mac输入，以及跳下一格的条件
     * */
    $('#macdz_id>input').bind('input propertychange', function () {
        //限制mac只能输入数字母
        var c = $(this);
        //截取输入的最后一个字符
        var lastStr = c.val().substr(c.val().trim().length - 1, 1);
        if (/[^\w]/.test(c.val())) {
            //替换非字母和数字字符，当输入不是字母或数字的时候用空替换
            var temp_amount = c.val().replace(/[^\w]/g, '');
            $(this).val(temp_amount);
            // 当前小格输入的最后一个字符是.并且长度不等于空
            if (/[-]/.test(lastStr) && $(this).val() != '') {
                $(this).next().focus();
            }
        }
        //当前小格输入长度为2时自动跳到下一格
        if ($(this).val().trim().length == 2) {
            $(this).next().focus();
        }
    })

    $('#macdz_id>input').bind('blur', function () {
        if ($(this).val().trim().length < 2) {
            $(this).focus();
            return false;
        }
        macc();
    })

    $('#macdz_id>.mac6').bind('blur', function () {
        if ($("#macdz_id>.mac6").val().trim().length < 2) {
            $("#macdz_id>.mac6").focus();
            return false;
        }
        macc();
    })

    /**
     * 限制ip输入，以及跳下一格的条件
     * */
    $('#ipdz_id>input').bind('input propertychange', function () {
        // 输入不是数字的时候清空
        var c = $(this);
        //截取输入的最后一个字符
        var lastStr = c.val().substr(c.val().trim().length - 1, 1);
        if (/[^\d]/.test(c.val())) {
            //替换非数字字符
            var temp_amount = c.val().replace(/[^\d]/g, '');
            $(this).val(temp_amount);
            // 当前小格输入的最后一个字符是.并且长度不等于空
            if (/[.]/.test(lastStr) && $(this).val() != '') {
                $(this).next().focus();
            }
        }
        // 第二，三，四位输入不在0-255之间的时候清空
        if ($(this).val() < 0 || $(this).val() > 255) {
            $(this).val('');
        }
        //第一位输入不在1-223之间的时候清空
        if ($("#ipdz_id>.ip1").val() < 1 || $("#ipdz_id>.ip1").val() > 223) {
            $("#ipdz_id>.ip1").val('');
        }
        //当每一小格输入的长度等于3时，自动跳到下一个
        if ($(this).val().trim().length == 3) {
            $(this).next().focus();
        }
        ipp();
    })

    /**
     * ip地址格式
     * 键盘按方向键上下左右，光标在四个input中来回切换
     */
    $('#ipdz_id>input').each(function (i, o) {
        $(this).attr('cust_index', i);
    })

    $('#ipdz_update>input').each(function (i, o) {
        $(this).attr('cust_index', i);
    })

    $('#ipdz_id>input').keydown(function (event) {
        var keycode = event.which;
        //从最后一个小格开始删除，删完之后直接跳到前一个小格中继续删除
        if (event.keyCode == 8 && $(this).val().length == 0) {
            $(this).prev().focus();
        }
        if (38 != keycode && 40 != keycode && 37 != keycode && 39 != keycode) {
            return;
        }
        var ti = $(this).attr('cust_index');
        if (39 == keycode || 40 == keycode) {
            //down
            ti++;
        } else {
            //up
            ti--;
        }
        if (ti < 0) {
            ti = 0;
        }
        var next_obj = $('#ipdz_id>input[cust_index=' + ti + ']');
        if (next_obj) {
            next_obj.focus();
        }
    })


    function sbbhchange() {
        var sel = document.getElementById("sbbh_sel")
        var sbmc_sel_xg = $("#sbbh_sel option:selected").text();
        var sbmc_sel_val = $("#sbbh_sel option:selected").val();
        var sbmc_sel_index = sel.selectedIndex + 1
        $('#ypdx_btn_1').attr("disabled", "disabled").unbind("click")
        $('#ypdx_btn_2').attr("disabled", "disabled").unbind("click")
        $('#ypdx_btn_3').attr("disabled", "disabled").unbind("click")
        $('#xsqcc_btn').attr("disabled", "disabled").unbind("click")
        $('#creat_sbbh_btn').removeAttr("disabled").bind("click", sbbhsc)
        // sbmc_index
        // var sbmc_sel_xinz = $("#sbbh_sel option:selected").val();

        $.confirm({
            title: '提示!',
            content: '您确定修改设备类型吗？确定请按确定(同时你添加的设备不是电脑或服务器，背景颜色是灰色的不用填写)，否则按取消',
            buttons: {
                confirm: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        $("#ypdx_id_1").val("");
                        $("#ypdx_id_2").val("");
                        $("#ypdx_id_3").val("");
                        $("#sbbh_id").val("")
                        $("#sbmc_id").val(sbmc_sel_xg)
                        $("#sbmc_option").val(sbmc_sel_val)
                        $("#sbmc_index").val(sbmc_sel_index)
                        $("#guige_id").val("")
                        $("#shccj_id").val("")
                        $("#gmrq_id").val("")
                        $("#bmid_id").val("")
                        $("#shiyr_id").val("")
                        $('#zbxh_id').val("")
                        $('#cpuxh_id').val("")
                        $('#ncggdx_id').val("")
                        $('#xkxh_id').val("")
                        $('#ypdx_id_1').val("")
                        $('#ypdx_id_2').val("")
                        $('#ypdx_id_3').val("")
                        $('#xsqppcc_id').val("")
                        $("#macdz_id>.mac1").val("")
                        $("#macdz_id>.mac2").val("")
                        $("#macdz_id>.mac3").val("")
                        $("#macdz_id>.mac4").val("")
                        $("#macdz_id>.mac5").val("")
                        $("#macdz_id>.mac6").val("")
                        $("#beiz_id").val("")
                        $("#ipdz_id>.ip1").val("")
                        $("#ipdz_id>.ip2").val("")
                        $("#ipdz_id>.ip3").val("")
                        $("#ipdz_id>.ip4").val("")
                        if (sbmc_sel_xg.indexOf("脑") < 0 && sbmc_sel_xg.indexOf("务器") < 0) {
                            $("#zbxh_id").attr("readOnly", "readOnly")
                            $("#cpuxh_id").attr("readOnly", "readOnly")
                            $("#ncggdx_id").attr("readOnly", "readOnly")
                            $("#xkxh_id").attr("readonly", "readonly")
                            $("#xsqppcc_id").attr("readOnly", "readOnly")
                            $('#ipdz1').attr("readOnly", "readOnly")
                            $('#ipdz2').attr("readOnly", "readOnly")
                            $('#ipdz3').attr("readOnly", "readOnly")
                            $('#ipdz4').attr("readOnly", "readOnly")
                            $('.mac1').attr("readOnly", "readOnly")
                            $('.mac2').attr("readOnly", "readOnly")
                            $('.mac3').attr("readOnly", "readOnly")
                            $('.mac4').attr("readOnly", "readOnly")
                            $('.mac5').attr("readOnly", "readOnly")
                            $('.mac6').attr("readOnly", "readOnly")
                            document.getElementById('xsqppcc_id').style.backgroundColor = "#eeeeee"
                            document.getElementById('ypdx_id_1').style.backgroundColor = "#eeeeee"
                            document.getElementById('ypdx_id_2').style.backgroundColor = "#eeeeee"
                            document.getElementById('ypdx_id_3').style.backgroundColor = "#eeeeee"
                            $('#ypdx_btn_1').attr("disabled", "disabled").unbind("click")
                            $('#ypdx_btn_2').attr("disabled", "disabled").unbind("click")
                            $('#ypdx_btn_3').attr("disabled", "disabled").unbind("click")
                            $('#xsqcc_btn').attr("disabled", "disabled").unbind("click")
                            $('#creat_sbbh_btn').removeAttr("disabled").bind("click", sbbhsc)
                        } else {
                            $("#zbxh_id").removeAttr("readOnly")
                            $("#cpuxh_id").removeAttr("readOnly")
                            $("#ncggdx_id").removeAttr("readOnly")
                            $("#xkxh_id").removeAttr("readonly")
                            $('#ipdz1').removeAttr("readOnly")
                            $('#ipdz2').removeAttr("readOnly")
                            $('#ipdz3').removeAttr("readOnly")
                            $('#ipdz4').removeAttr("readOnly")
                            $('.mac1').removeAttr("readOnly")
                            $('.mac2').removeAttr("readOnly")
                            $('.mac3').removeAttr("readOnly")
                            $('.mac4').removeAttr("readOnly")
                            $('.mac5').removeAttr("readOnly")
                            $('.mac6').removeAttr("readOnly")
                            document.getElementById('ypdx_id_1').style.backgroundColor = "#ffffff"
                            document.getElementById('ypdx_id_2').style.backgroundColor = "#ffffff"
                            document.getElementById('ypdx_id_3').style.backgroundColor = "#ffffff"
                            document.getElementById('xsqppcc_id').style.backgroundColor = "#ffffff"
                            $('#ypdx_btn_1').removeAttr("disabled").bind("click", ypdx_1)
                            $('#ypdx_btn_2').removeAttr("disabled").bind("click", ypdx_2)
                            $('#ypdx_btn_3').removeAttr("disabled").bind("click", ypdx_3)
                            $('#xsqcc_btn').removeAttr("disabled").bind("click", xsqxx)
                            $('#creat_sbbh_btn').removeAttr("disabled").bind("click", sbbhsc)
                        }
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                        var sbmc_xin_option = $("#sbmc_option").val()
                        sel.value = sbmc_xin_option;
                    },
                }
            }
        });
    }
</script>
</body>
</html>